package com.example.attendancesystem_1_8;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.fragment.app.Fragment;

import com.example.attendancesystem_1_8.MyContacts.ContactAdapter;
import com.example.attendancesystem_1_8.entity.Contacts;

import java.util.ArrayList;
import java.util.List;

//import android.support.v4.app.Fragment;

//即FrdFragment
public class CntFragment extends Fragment
{

    private ListView lv_contacts;
    private ContactAdapter contactAdapter;
    private List<Contacts> contactsList = new ArrayList<>();
    private int pictureUrl2_1 = R.drawable.picture1;
    private int pictureUrl2_2 = R.drawable.arrow_right;
    private int pictureUrl2_3 = R.drawable.head_test;

    public CntFragment()
    {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        return inflater.inflate(R.layout.tab02, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState)
    {
        super.onActivityCreated(savedInstanceState);

        lv_contacts = getActivity().findViewById(R.id.lv_contacts);
        contactAdapter = new ContactAdapter(contactsList, getActivity());
        lv_contacts.setAdapter(contactAdapter);

        Contacts contacts_1 = new Contacts("艾孜尔", "12345601", "主管", pictureUrl2_2);
        Contacts contacts_2 = new Contacts("原野", "12345602", "老板", pictureUrl2_3);
        Contacts contacts_3 = new Contacts("冯谦", "12345603", "员工", pictureUrl2_1);
        Contacts contacts_4 = new Contacts("孙飞鸿", "12345604", "员工", pictureUrl2_2);
        Contacts contacts_5 = new Contacts("金章宇", "12345605", "员工", pictureUrl2_3);
        Contacts contacts_6 = new Contacts("徐冉", "12345606", "员工", pictureUrl2_1);

        contactsList.add(contacts_1);
        contactsList.add(contacts_2);
        contactsList.add(contacts_3);
        contactsList.add(contacts_4);
        contactsList.add(contacts_5);
        contactsList.add(contacts_6);

        contactAdapter.notifyDataSetChanged();


    }

}
